package com.ranjiaqi.string;

/**
 * @ClassName TestConstructString
 * @Description TODO
 * @Author hp
 * @Date 2021/6/19 10:33
 * @Version 1.0
 **/
public class TestConstructString {
    public static void main(String[] args) {
        function();
    }

    /**
     * Stirng(byte[] b) 构造方法传递字节数组,字节数组变成字符串
     * 按照平台默认的编码表执行
     * 网络数据传输
      */

    public static void function(){
        byte[] bytes ={97,98,99,100,101};
        String str = new String(bytes);
        System.out.println("str = " + str);

        byte[] bytes1 = {-28,-67,-127};
        String str2 = new String(bytes1);
        System.out.println("str2 = " + str2);
    }
}
